home *** CD-ROM | disk | FTP | other *** search
- /*
- This code was created by Keith Evans, MMATS, Inc. with alot of
- help from others whom I met on the GEnie network service.
-
- This code fragment will initialize the SCC chip to receive serial
- data from the modem port. The data consists of 8 data bits, 1 stop
- bit, no parity, and the clocking will come from the "HSKi" pin. The
- data is received at the same rate as the clock (1X mode).
-
- I wish to thank the makers of THINK's LightSpeed C for a very good
- development environment, at least VERY good for this programmer!
-
-
- */
-
- #define NULL 0L
- #define aCtl 2 /* controls for the modem port */
- #define aData 6 /* data from the modem port */
-
- #define PAUSE asm {move.l (SP),(SP)} /* to avoid overdriving the SCC */
-
- #define ZERO(thereg) asm {move.b #0,(thereg)} /* because LSC doesn't */
- /* know from volatile & */
- /* will generate clrs */
-
-
- /* main program */
-
- main()
- {
- int vRef;
- Str255 fn;
-
- InitMac();
- SCCSetup(); /* Initialize SCC */
-
- }
-
- SCCSetup() { /* configure SCC */
- char toss;
- register char *SCCWR0 = (SCCWr + aCtl);
- register char *SCCRD0 = (SCCRd + aCtl);
-
- toss = *SCCRD0; /* read SCC to reset it */
- PAUSE
- *SCCWR0 = 0x9;
- PAUSE
- *SCCWR0 = 0x88; /* reset the SCC channel A & enable all interrupts */
- PAUSE
- *SCCWR0 = 0x1;
- PAUSE
- *SCCWR0 = 0x1; /* disable Rx interrupts & enable external status interrupts */
- PAUSE
- *SCCWR0 = 0x4;
- PAUSE
- *SCCWR0 = 0x4; /* X1 clock mode & 1 stop bit */
- PAUSE
- *SCCWR0 = 0x2;
- PAUSE
- ZERO(SCCWR0) /* reset all interrupt vectors */
- PAUSE
- *SCCWR0 = 0x3;
- PAUSE
- *SCCWR0 = 0xC0; /* Rx 8 bits/character */
- PAUSE
- *SCCWR0 = 0x5;
- PAUSE
- *SCCWR0 = 0x60; /* Tx 8 bits/character */
- PAUSE
- *SCCWR0 = 0xA;
- PAUSE
- ZERO(SCCWR0) /* NRZ encoding */
- PAUSE
- *SCCWR0 = 0xB;
- PAUSE
- *SCCWR0 = 0x30; /* TTL input, use TRxC for Rx & BR generator for Tx, TRxC input */
- PAUSE
- *SCCWR0 = 0xE;
- PAUSE
- *SCCWR0 = 0x1; /* enable baud generator */
- PAUSE
- *SCCWR0 = 0x3;
- PAUSE
- *SCCWR0 = 0xC1; /* enable receiver */
- PAUSE
- *SCCWR0 = 0x5;
- PAUSE
- *SCCWR0 = 0x60; /* RTS high */
- PAUSE
- *SCCWR0 = 0xF;
- PAUSE
- *SCCWR0 = 0x8; /* enable mouse interrupts */
- }
-
-